<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>返回顶部</title>
    <link href="learningstyle.css" rel="stylesheet">
</head>
<body>
    <div id="B-main" class="block">
        hello world!!
    </div>
    <div id="B-xuanfu" class="xuanfu">返回顶部</div>
    <script type="text/javascript">
        document.getElementById("B-xuanfu").onclick = function () {

            document.documentElement.scrollTop = document.body.scrollTop = 0;

        }
    </script>
</body>
</html>